<template>
	<view class="">
		<u-empty text="暂无信息" mode="list" v-if="!load&&!baseInfo"></u-empty>
		<view class="medicine" v-show="baseInfo">
			<view class="section-box">
				<u-section title="患者信息" :right="false" :bold='false' :line-color='themeColorLight' color="#000000"></u-section>
			</view>
			<view class="medicine-header">
				<view class="card-row"><label>患者姓名：</label>{{baseInfo.hzxm||''}}</view>
				<view class="card-row"><label>开单科室：</label>{{baseInfo.ksmc||''}}</view>
				<view class="card-row"><label>开单医生：</label>{{baseInfo.ysmc||''}}</view>
				<view class="card-row"><label>病历号：</label>{{baseInfo.blh||''}}</view>
			</view>
			<view class="div-cut"></view>
			<view class="medicine-main">
				<u-table border-color='#fff'>
					<u-tr class="u-tr">
						<u-th class="u-th">药品名称</u-th>
						<u-th class="u-th">数量</u-th>
						<u-th class="u-th">规格</u-th>
						<u-th class="u-th">医嘱</u-th>
					</u-tr>
					<u-tr class="u-tr" v-for="(item, i) in dataList" :key='i'>
						<u-td class="u-td">{{item.ypmc||''}}</u-td>
						<u-td class="u-td">{{item.ypsl||''}}</u-td>
						<u-td class="u-td">{{item.ypgg||''}}</u-td>
						<u-td class="u-td">{{item.yznr||''}}</u-td>
					</u-tr>
				</u-table>
			</view>
		</view>
		<Load :load="load" />
	</view>
</template>

<script>
	import { themeColorLight } from '@/static/js/theme.js'
	import { getTakeMedicine } from '@/api/home.js'
	import Load from '@/components/Load/index.vue'
	export default {
		components:{ Load },
		data() {
			return {
				themeColorLight,
				load:true,
				dataList:[],
				queryInfo:'',
				baseInfo:''
			}
		},
		onLoad(op) {
			if(op.query){
				this.queryInfo = JSON.parse(op.query)
				this.initData()
			}
			if(op.params) {
				this.dataList = JSON.parse(op.params)
				this.baseInfo = this.dataList[0]||''
			}
		},
		methods: {
			initData(){
				// this.load = true
				getTakeMedicine(this.queryInfo).then(data => {
					this.load = false
					this.dataList = data||[]
					this.baseInfo = this.dataList[0]||''
				}).catch(e => {
					this.dataList = []
					this.baseInfo = ''
					this.load = false
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.medicine{
		height: calc(100vh);
		overflow: scroll;
		background-color: $uni-bg-color;
		.section-box{
			padding: 30rpx 0 0 30rpx;
		}
		&-header{
			padding:20rpx;
		}
		&-main{
			padding: 30rpx;
		}
	}
</style>
<style lang="scss">
	.u-tr{
		border: 1px solid #f8f8f8;
		border-top: none;
		>view{
			word-wrap:break-word; 
			word-break:break-all;
		}
	}
</style>
